unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TMan = class(TObject)
  public
    Code:Integer;
    Sex :Integer;
  public
  end;

  TForm1 = class(TForm)
    ListBox1: TListBox;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }

  public
    { Public declarations }
    procedure RendListBox(AStrs:Tstringlist);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  I:Integer;
  AStrs:TStringList;
  AMan :TMan;
begin
  AStrs:=TStringList.Create;
  for I:=0 to 9 do
  begin
    AMan:=TMan.Create;
    AMan.Code:=I;
    AMan.Sex :=0;
    AStrs.AddObject(IntToStr(AMan.Code),AMan);
  end;

  if AStrs.IndexOf('4')<>-1 then
  begin
    AMan:=TMan(AStrs.Objects[4]);
    AMan.Sex:=1;       
  end;
  RendListBox(AStrs);
end;

procedure TForm1.RendListBox(AStrs: Tstringlist);
var
  I:Integer;
  AMan:TMan;
  Temp:string;
begin
  ListBox1.Items.Clear;
  for I:=0  to AStrs.Count-1 do
  begin
    AMan:=TMan(AStrs.Objects[I]);
    Temp:=Format('%d|%d',[AMan.Code,AMan.Sex]);
    ListBox1.Items.Add(Temp);
  end;
end;

end.
